<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class CheckboxItem extends FormItem implements IRenderable {
	protected $allowEmptyValue;
	
	protected $labelAsTitle;
	
	protected $showLabel;
	protected $showTitle;
	protected $showUnsetImage;
	
	protected $titleStyle;
	
	protected $checkedImage;
	protected $uncheckedImage;
	protected $unsetImage;
	protected $partialSelectedImage;
	
	protected $valueMap;
	
	/**
	 * Constructeur
	 * @param unknown_type $name
	 */
	public function CheckboxItem ($name, $uncheckedValue = 0, $checkedValue = 1) {
		parent::FormItem($name, Constant::EDITOR_TYPE_CHECKBOX);
		
		$this->valueMap = new CheckboxValues($uncheckedValue, $checkedValue);
	}

	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de properties
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class CheckboxValues implements IRenderable {
	
	private $trueVal;
	private $falseVal;
	
	public function CheckboxValues($uncheckedValue = 0, $checkedValue = 1) {
		$this->falseVal = $uncheckedValue;
		$this->trueVal = $checkedValue;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return null;
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return null;
	}
	
	/**
	 * Implementation de properties
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		//
	}
	
	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		return "{\"".$this->falseVal."\":false, \"".$this->trueVal."\":true}";
	}
}
?>
